﻿/************************************************************************
* Copyright (c) 2018 All Rights Reserved.
* 命名空间：ZTService.Bet
* 文件名：BetHttpData
* 创建人：David Rodríguez
* 创建时间：2018/7/31 星期二 13:58:37
* 描述： HTTP获取相关信息
*************************************************************************/

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using DavidHelper;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using ZTService.Modle;

namespace ZTService.Bet
{
    public class BetHttpData
    {
        private static readonly string Pk10DataUrl = "http://125.88.183.193:8080/api/Bet/GetPk10";

        private static readonly string CqsscDataUrl = "http://125.88.183.193:8080/api/Bet/GetCqssc";


        public static CaiPiaoModel GetLastKj(KindId id)
        {
            if (id.ToString().Equals("重庆时时彩"))
            {
                return AlaysisJson(CqsscDataUrl);
            }
            else if (id.ToString().Equals("北京赛车"))
            {
                return AlaysisJson(Pk10DataUrl);
            }
            else
            {
                return null;
            }
        }


        private static CaiPiaoModel AlaysisJson(string url)
        {
            var json = HttpHelper.Get(url, null);
            var model = new CaiPiaoModel();
            var obj2 = (JObject) JsonConvert.DeserializeObject(json);
            model.Expect = obj2["data"][0]["expect"].ToString();
            model.Opencode = obj2["data"][0]["opencode"].ToString();
            return model;
        }

    }
}